import request from "@/utils/request";

export const add = (params) => {
  const { code, type, start, startPinyin, startTime, end, endPinyin, endTime } = params;
  return request.post("/system/train/add", {
    code, type, start, startPinyin, startTime, end, endPinyin, endTime
  });
};

export const getPage = (pageNo, pageSize, search) => {
  const { code } = search;
  return request.post("/system/train/page", {
    pageNo,
    pageSize,
    code
  });
};

export const remove = (id) => {
  return request.delete(`/system/train/remove/${id}`);
};

export const edit = (params) => {
  const { id, code, type, start, startPinyin, startTime, end, endPinyin, endTime } = params;
  return request.post("/system/train/edit", {
    id, code, type, start, startPinyin, startTime, end, endPinyin, endTime
  });
};

export const generateSeat = (trainCode) => {
  return request.post("/system/train/generate-seat", {
    trainCode
  });
};

//获取详情
export const getTrainDetail = (trainCode) => {
  return request.post(`/system/train/detail/${trainCode}`);
};